<?php
/**
 * --------------------------------------------------------------
 * 字段验证器
 * --------------------------------------------------------------
 * Light Year Doc
 * @author yinq<3331653644@qq.com>
 * --------------------------------------------------------------
 */
namespace app\admin\validate;

use think\Validate;

class Field extends Validate
{
    //定义验证规则
    protected $rule = [
        'title|字段名称'      => 'require|length:1,30',
        'en_title|字段英文名' => 'require|regex:^[a-z]\w{0,39}$|unique:field,en_title^model_id',
        'type|字段类型'       => 'require|length:1,30',
        'define|字段定义'     => 'require|length:1,100',
        'remark|字段说明'     => 'length:1,200',
    ];

    //定义验证提示
    protected $message = [
        'en_title.regex' => '字段英文名称由小写字母和下划线组成',
    ];
}